import cn.uyunsky.platform.config.ConfigFactory;
import cn.uyunsky.platform.config.bean.menu.PlTree;
import cn.uyunsky.platform.config.reader.MenuReader;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

/**
 * 测试push
 */
public class Test {

    public static void main(String[] args) {
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:/spring/core.xml");
        DataSource dataSource = (DataSource) applicationContext.getBean("dataSource");
        Connection conn = null;
        try {
            conn = dataSource.getConnection();
            System.out.println(conn);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            if (conn != null) try {
                conn.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }

        ConfigFactory configFactory = (ConfigFactory) applicationContext.getBean("configFactory");
        MenuReader reader = configFactory.getReader(MenuReader.class);
        System.out.println("reader-->"+reader);
        PlTree pltree = reader.getTree("menu");
        System.out.println("pltree-->"+pltree);


    }

}
